﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace TheCup
{
    [Table("matchplayresults")]
    public class MatchPlayResult
    {
        [Key]
        public int Id { get; set; }

        [Column("dateentry")]
        [Display(Name="dato")]
        [DataType(DataType.Date)]
        public DateTime Date { get; set; }

        public int HolesUp { get; set; }

        [Column("player1no")]
        public int Player1Id { get; set; }

        [Column("player2no")]
        public int Player2Id { get; set; }

        [Column("winnerplayerno")]
        public Nullable<int> WinnerPlayerId { get; set; }

        [ForeignKey("Player1Id")]
        public Player Player1 { get; set; }

        [ForeignKey("Player2Id")]
        public Player Player2 { get; set; }

        [ForeignKey("WinnerPlayerId")]
        public Player WinningPlayer { get; set; }

        public DateTime WhenCreated { get; set; }

        /// <summary>
        /// Only used for posting
        /// </summary>
        [NotMapped]
        public string ResultString { get; set; }
    }

}